package com.miyake.dsp.converter.ui;

import com.miyake.dsp.converter.MovingAverageSetting;
import com.miyake.dsp.ui.DspTextField;
import com.miyake.dsp.ui.DspWidget;

public class MovingAverageUI extends DspWidget{

	private MovingAverageSetting setting;

	public MovingAverageUI(MovingAverageSetting setting) {
		this.setName("Moving Average");
		this.setting = setting;
		createLength();
	}
	
	private void createLength() {
		DspTextField text = new DspTextField("Length");
		text.setValue(String.valueOf(setting.getLength()));
		this.add(text);
		
		text.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				setting.setLength(Integer.valueOf(value));
				fireChange(value);
			}
		});	
	}
}
